package com.netease.financial.internal.di.modules;

import android.content.Context;
import android.util.DisplayMetrics;

import com.netease.financial.base.register.RegisterPresenterImpl;
import com.netease.financial.base.register.RegisterPresenter;
import com.netease.financial.common.constant.Constants;
import com.netease.financial.domain.Factory;
import com.netease.financial.domain.executor.PostExecutionThread;
import com.netease.financial.domain.executor.ThreadExecutor;
import com.netease.financial.domain.interactor.GetPageInfo;
import com.netease.financial.domain.interactor.Register;
import com.netease.financial.domain.interactor.UseCase;
import com.netease.financial.domain.repository.NfsRepository;
import com.netease.financial.internal.di.ActivityScope;

import java.util.ArrayList;
import java.util.List;

import javax.inject.Named;

import dagger.Module;
import dagger.Provides;

/**
 * Created by hzwuyufeng on 3/8/16.
 */
@Module
public class RegisterModule {
    private static final String PAGE_NAME = "register";
    private final List<String> elements = new ArrayList<>();

    public RegisterModule() {
    }

    @Provides
    @ActivityScope
    RegisterPresenter provideRegisterPresenter(RegisterPresenterImpl registerPresenter) {
        return registerPresenter;
    }

    @Provides
    @ActivityScope
    @Named("page_info")
    UseCase provideGetPageInfoUseCase(Context context, NfsRepository nfsRepository,
                                      ThreadExecutor threadExecutor,
                                      PostExecutionThread postExecutionThread) {
        DisplayMetrics displayMetrics = context.getResources().getDisplayMetrics();
        return new GetPageInfo(PAGE_NAME, elements, displayMetrics.widthPixels, displayMetrics.heightPixels,
                Constants.PLATFORM, nfsRepository, threadExecutor, postExecutionThread);
    }

    @Provides
    @ActivityScope
    @Named("register")
    UseCase provideRegisterUseCase(NfsRepository nfsRepository, ThreadExecutor threadExecutor, PostExecutionThread postExecutionThread) {
        return new Register(nfsRepository, threadExecutor, postExecutionThread);
    }
}
